package com.codyy.charts.chartsapplication;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextPaint;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.codyy.mobile.support.chart.BarChartView;
import com.codyy.mobile.support.chart.DisplayUtil;

import java.util.Random;

/**
 * Created by lijian on 2018/3/2.
 */

public class MainActivity extends AppCompatActivity {
    BarChartView barChartView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_m);
        barChartView = findViewById(R.id.bar_char_view);
        Random random = new Random();
        int[] bar1 = new int[12];
        int[] bar2 = new int[12];
        int[] line = new int[12];
        String[] xLabels = new String[12];
        for (int i = 0; i < 12; i++) {
            bar1[i] = 300;
            if (i % 2 == 0) {
                bar2[i] = 500;
                line[i] = 0;
            } else {
                bar2[i] = 493;
                line[i] = random.nextInt(100);
            }
            xLabels[i] = "2019-" + (i < 9 ? "0" + (i + 1) : (i + 1));
        }
        barChartView.setData(bar1, bar2, line, xLabels);
        TextPaint textPaint = new TextPaint();
        textPaint.setTextSize(DisplayUtil.dip2px(this, 16f));
        Log.d("MainActivity", Math.abs(textPaint.getFontMetrics().ascent) + Math.abs(textPaint.getFontMetrics().descent) + "");
    }

    public void circlePercent(View view) {
        startActivity(new Intent(this, CirclePercentChartActivity.class));
    }

    public void dashboard(View view) {
        startActivity(new Intent(this, DashBoardActivity.class));
    }

    public void dashboardRate(View view) {
        startActivity(new Intent(this, DashBoardRateChartActivity.class));
    }

    public void gradientRoundedRectangle(View view) {
        startActivity(new Intent(this, GradientRoundedRectangleActivity.class));
    }

    public void gradientLine(View view) {
        startActivity(new Intent(this, GradientLineAcitity.class));
    }

    public void donuts(View view) {
        startActivity(new Intent(this, DonutsActivity.class));
    }

    public void graph(View view) {
        startActivity(new Intent(this, GraphChartActivity.class));
    }

    public void bar(View view) {
        startActivity(new Intent(this, BarChartActivity.class));
    }

    public void poly(View view) {
        startActivity(new Intent(this, PolyChartActivity.class));
    }
}
